<template>
	<view>
		<InputFactory v-for="(item,index) in inputList" :name="item" ref="myComponent"></InputFactory>
	</view>
</template>

<script>
	import InputFactory from "../InputFactory/InputFactory.vue"
	const formMap={
		login_id:['id','password'],
		login_phone:['phone','code'],
		register:['username','password','repassword','phone','code'],
		retrieve:['id','phone','code','password','repassword']
	}
	export default{
		name:'Form',
		props:{
			type:''
		},
		created() {
			console.log(111111111111111111)
			console.log(this.type)
		},
		computed:{
			inputList(){
				return formMap[this.type]
			}
		},
		components:{InputFactory},
		methods:{
			getlst(){
				let lst=[]
				var i=0
				console.log(this.$refs)
				for(i=0;i<formMap[this.type].length;i++){
					// const refName = `${'myComponent'+i}`
					// console.log(refName)
					 console.log(this.$refs.myComponent[i])
					// if(this.$refs[refName]===this.$refs.myComponent0){
					// 	console.log(true)
					// }
					// else{
					// 	console.log(false)
					// }
					// lst.push(this.$refs[refName].getinput())
					lst.push(this.$refs.myComponent[i].getinput())
				}
				return lst
				// console.log(lst)
			}
		}
		
	}
</script>

<style>
</style>
